import message from "@wanhu/antd-legacy/lib/message";
import { Button, Checkbox, Col, Input, Modal, Row, Select } from "antd";
import { cloneDeep, debounce } from "lodash";
import moment from "moment";
import React, { Component } from "react";
import api from "../../../api/api";
import history from "../../../history";
import { connectRouter } from "../../../mixins/router";
import { connect as connectState } from "../../../states/insurance/insuranceOrderList";
import { DateRangePicker } from "../../common/DateRangePicker";
import { Form } from "../../common/form";
import HasPermission, { testPermission } from "../../common/HasPermission";
import { TablePage } from "../../common/table-page";
// 会员卡片弹窗
import CustomerCart from "../../customerCenter/CustomerCard";
// 订单问询激活弹窗
// import c from "./activateModal.jsx";
import '../../insurance/InsuranceOrder/index.css'
import './patientInsuranceOrderList.scss'
const TableColumn = TablePage.Column;

const QueryKeyChoices = [
  {
    value: "1",
    label: "服务对象",
  },
  {
    value: "5",
    label: "购买人",
  },
  {
    value: "2",
    label: "对象身份证号",
  },
  {
    value: "4",
    label: "销售渠道码",
  },
  {
    value: "3",
    label: "会员服务单",
  },
];

const isPayStatusChoices = [
  { value: "0", label: "待支付" },
  { value: "1", label: "已支付" },
  { value: "2", label: "支付失败" },
];

const payType = [
  { value: "1", label: "年缴" },
  { value: "2", label: "月缴" },
  { value: "3", label: "季缴" },
];
const orderTypes = [
  { value: "0", label: "待确认" },
  { value: "1", label: "已确认" },
  { value: "2", label: "待激活" },
  { value: "3", label: "已承保" },
  { value: "4", label: "已完成" },
  { value: "5", label: "已出险" },
  { value: "6", label: "已撤单" },
  { value: "7", label: "失效" },
];

const mapChoiceToOption = (choice, i) => (
  <Select.Option key={i} value={choice.value}>
    {choice.label}
  </Select.Option>
);

const tableDef = TablePage.def({
  type: {
    parse: (val) => val || "1",
    stringify: (val) => (val === "1" ? undefined : val),
  },
  search: {},
  packageId: {},
  payWay: {},
  startTime: {
    parse: (val) =>
      val
        ? val.split(",").map((s) => {
            if (!s) return undefined;
            const m = moment(s);
            return m.isValid() ? m : undefined;
          })
        : undefined,
    stringify: (val) =>
      val
        ? val
            .map((d) => (d && moment.isMoment(d) ? d.format("YYYY-MM-DD") : ""))
            .join(",")
        : undefined,
  },
  payStatus: {},
  status: {},
});

// 获取URL参数
function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i = 0; i < vars.length; i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  }
  return false;
}

class InsuranceOrder extends Component {
  constructor(props) {
    super(props);
    this.state = {
      visible: false,
      insurId: null,
      confirmDate: null,
      confirmDateExplain: null,
      canshow: false,
      packageId: undefined,
      customerCardVisible: false,
      currentCustomerId: null,
      activateModalShow: false, // 激活弹窗是否展示
      orderInfo: null, // 需要激活的订单信息
      enquiryList: [], // 问询列表
    };
    this.search = ''
  }
  componentWillReceiveProps(props) {
    this.setState({
      packageId: undefined,
    });
    if (this.props.router.modal === "insuranceOrder" && !props.router.modal) {
      this.table.reload();
    }
  }
  componentWillUpdate(){
      if(this.search !== window.location.search){
        this.search = window.location.search
        this.initData()
      }

  }


  async componentDidMount() {
    this.initData()

    // if (
    //   getQueryVariable("buyServiceStatus") &&
    //   getQueryVariable("teamOrderNo")
    // ) {
    //   if (getQueryVariable("buyServiceStatus") === "0") {
    //     try {
    //       const data = await api.insureInsureOrderNo(
    //         getQueryVariable("teamOrderNo"),
    //         []
    //       );
    //       if (data) {
    //         message.success("激活成功");
    //       } else {
    //         message.error("激活失败");
    //       }
    //       setTimeout(() => {
    //         this.table.reload();
    //       }, 100);
    //     } catch (error) {
    //       // message.error(error.message || '已经激活过，不需要重新激活');
    //       setTimeout(() => {
    //         window.location.href = "/patientInsurance";
    //       }, 100);
    //     }
    //   } else {
    //     message.error("激活失败");
    //   }
    // }

    // this.setState({
    //   packageId: undefined,
    // });
    // const list = await api.getInsuracePackage();
    // this.setState({
    //   insurancePackage: [...list],
    //   insurancePackage2: cloneDeep(list),
    // });
    // setTimeout(() => {
    //   this.setState({
    //     packageId: undefined,
    //   });
    // }, 0);

  }
  initData = ()=>{
    let searchName = this.props.customerName
    let pageIndex = +getQueryVariable('p') || 1
    let pageSize = +getQueryVariable('ps') || 10
    this.loadData({values:{type:1,search:searchName},pageIndex:pageIndex,pageSize:pageSize})
  }
  componentWillUnmount() {
    this.props.resetInsurancesOrderList();
  }

  loadData = ({ values, pageIndex, pageSize }) => {
    const where = {};
    if (values.startTime && values.startTime.length > 0) {
      if (values.startTime[0]) {
        where.startDate = values.startTime[0].format("YYYY-MM-DD");
      }
      if (values.startTime[1]) {
        where.endDate = values.startTime[1].format("YYYY-MM-DD");
      }
    }
    where.type = values.type;
    let search = values.search;
    where.search = search ? search.replace(/\s*/g, "") : null;
    where.packageId = values.packageId;
    where.status = values.status;
    where.payWay = values.payWay;
    where.payStatus = values.payStatus;
    this.props.searchInsurancesOrderList(where, pageIndex, pageSize);
  };

  resetData = () => {
    this.props.resetInsurancesOrderList();
  };

  openNewOrderInsuranceModal = () => {
    this.props.router.openModal("newPatientInsurance");
  };
  exportData = (values) => {
    const where = {};
    if (values.startTime && values.startTime.length > 0) {
      if (values.startTime[0]) {
        where.startDate = values.startTime[0].format("YYYY-MM-DD");
      }
      if (values.startTime[1]) {
        where.endDate = values.startTime[1].format("YYYY-MM-DD");
      }
    }
    where.type = values.type;
    let search = values.search;
    console.log(typeof search);
    where.search = search ? search.replace(/\s*/g, "") : null;
    where.packageId = values.packageId;
    where.status = values.status;
    where.payWay = values.payWay;
    where.payStatus = values.payStatus;

    // let exportFile = api.exportInsuranceData(values)
    let valueStr = "";
    for (let item in where) {
      if (where[item]) {
        valueStr += item + "=" + encodeURIComponent(where[item]) + "&";
      }
    }
    console.log("valueStr:", valueStr);
    window.open(`/_api/patient/insurance_order/export?${valueStr}`, "_blank");
  };

  showDetail = (insurance) => {
    history.push(
      `/patientInsuranceDetail/${insurance.orderId}?r=${encodeURIComponent(
        this.props.router.fullPath
      )}`
    );
  };

  updateInsurance = (insurance) => {
    this.props.router.openModal("newPatientInsurance", insurance.insurId);
  };

  openConfirmModal = (insurance) => {
    this.setState({ visible: true, insurId: insurance.insurId });
  };

  cancelInsurance = (insurance) => {
    Modal.confirm({
      title: `该操作不可撤销，且被作废的投保单号不可再用。确认作废吗？`,
      onOk: () => {
        this.props.cancelGroupInsurance(insurance.insurId);
      },
      onCancel() {},
    });
  };

  insuranceConfirmation = () => {
    const { insurId, confirmDate } = this.state;
    if (!confirmDate) {
      this.setState({ confirmDateExplain: "不能为空" });
    } else {
      this.props.confirmGroupInsurance(insurId, confirmDate);
      this.setState({
        visible: false,
        confirmDate: null,
        insurId: null,
        confirmDateExplain: "",
      });
    }
  };

  finishConfirmStatus = () => {
    message.success("承保确认成功", 3);
    this.table.reload({ scrollToTop: false });
  };
  finishCancelStatus = () => {
    message.success("投保单已作废", 3);
    this.table.reload({ scrollToTop: false });
  };

  onCheckChange(e) {
    this.setState({
      ischeck: e.target.checked,
    });
  }

  judgeTime(time) {
    var strtime = time.replace("/-/g", "/"); //时间转换
    //时间
    var date1 = new Date(strtime);
    //现在时间
    var date2 = new Date();
    //判断时间是否过期
    return date1 < date2 ? true : false;
  }

  renderModal() {
    const { canshow, selectOrder, ischeck } = this.state;
    const nowdata = this.props.getInsuranceRevokeOrderInfo;
    let ast = null;
    if (nowdata.status == "fulfilled") {
      ast = nowdata.payload;
    }
    const isover = ast && ast.deadline ? this.judgeTime(ast.deadline) : false;
    const renderText = () => {
      if (ast) {
        if (!ast.payStatus) {
          return <Col>该订单尚未支付，确认撤单？</Col>;
        }
        if (ast.orderStatus == 0 || ischeck) {
          // 待确认
          return (
            <Col>
              该订单可<span style={{ color: "#1da57a" }}>全额退款</span>
              ，具体退款明细如下：
            </Col>
          );
        } else if (ast.orderStatus != 0 && ast.isUse) {
          // 其他状态 判断是否在使用 - 在使用
          return (
            <Col>
              该订单已使用以下服务，正常情况
              <span style={{ color: "red" }}>不可退款</span>
            </Col>
          );
        } else if (ast.orderStatus != 0 && !ast.isUse) {
          // 不在使用中
          if (isover) {
            return (
              <Col>
                该订单已过犹豫期（{ast.deadline}），正常情况
                <span style={{ color: "red" }}>不可退款</span>
              </Col>
            );
          } else {
            return (
              <Col>
                该订单可<span style={{ color: "#1da57a" }}>全额退款</span>
                ，具体退款明细如下：
              </Col>
            );
          }
        }
      }
    };
    return (
      <Modal
        title="撤单确认"
        visible={canshow}
        width={500}
        maskClosable={false}
        onCancel={this.hideModal.bind(this)}
        style={{ backgroundColor: "#f8f8f8" }}
        footer={
          <Row>
            <Button
              onClick={this.submit.bind(this)}
              type="primary"
              disabled={
                (ast && ast.isUse && !this.state.ischeck && ast.payStatus) ||
                (ast &&
                  !ast.isUse &&
                  isover &&
                  !this.state.ischeck &&
                  ast.payStatus)
                  ? true
                  : false
              }
              loading={false}
            >
              确认撤单
            </Button>
            <Button
              onClick={this.hideModal.bind(this)}
              className="cancelButton"
            >
              取消
            </Button>
          </Row>
        }
      >
        <Row style={{ marginBottom: 15 }}>{renderText()}</Row>
        {ast && ast.payStatus
          ? ast.orderStatus == 0 &&
            ast.payments &&
            ast.payments.length &&
            ast.payments.map((i, index) => {
              return (
                <Row key={index}>
                  <Col span={10}>{`${i.paymentTypeName}`}</Col>
                  <Col span={6}>
                    {`${i.amount}`}
                    {i.paymentName == "self_pbm_points_deduction"
                      ? "积分"
                      : "元"}
                    {ast.orderStatus != 0 && !ast.isUse && isover
                      ? `(扣${i.deductAmount}${
                          i.paymentName == "self_pbm_points_deduction"
                            ? "分"
                            : "元"
                        })`
                      : ""}
                  </Col>
                </Row>
              );
            })
          : null}
        {ast && ast.payStatus
          ? ast.orderStatus != 0 &&
            ast.isUse &&
            !ischeck &&
            ast.products &&
            ast.products.length &&
            ast.products.map((i, index) => {
              return (
                <Row key={index}>
                  <Col span={8}>{`${i.productName}`}</Col>
                  {i.usageCounter === null ? null : (
                    <Col span={6}>{`${i.usageCounter}次`}</Col>
                  )}
                </Row>
              );
            })
          : null}
        {ast && ast.payStatus
          ? ast.orderStatus != 0 &&
            ast.isUse &&
            ischeck &&
            ast.payments &&
            ast.payments.length &&
            ast.payments.map((i, index) => {
              return (
                <Row key={index}>
                  <Col span={10}>{`${i.paymentTypeName}`}</Col>
                  <Col span={6}>
                    {`${i.amount}`}
                    {i.paymentName == "self_pbm_points_deduction"
                      ? "积分"
                      : "元"}
                    {ast.orderStatus != 0 && !ast.isUse && isover
                      ? `(扣${i.deductAmount}${
                          i.paymentName == "self_pbm_points_deduction"
                            ? "分"
                            : "元"
                        })`
                      : ""}
                  </Col>
                </Row>
              );
            })
          : null}
        {ast && ast.payStatus
          ? ast.orderStatus !== 0 &&
            isover &&
            !ast.isUse &&
            ischeck &&
            ast.payments &&
            ast.payments.length &&
            ast.payments.map((i, index) => {
              return (
                <Row key={index}>
                  <Col span={10}>{`${i.paymentTypeName}`}</Col>
                  <Col span={6}>
                    {`${i.amount}`}
                    {i.paymentName == "self_pbm_points_deduction"
                      ? "积分"
                      : "元"}
                    {ast.orderStatus != 0 && !ast.isUse && isover
                      ? `(扣${i.deductAmount}${
                          i.paymentName == "self_pbm_points_deduction"
                            ? "分"
                            : "元"
                        })`
                      : ""}
                  </Col>
                </Row>
              );
            })
          : null}
        {ast && ast.payStatus
          ? ast.orderStatus !== 0 &&
            !isover &&
            !ast.isUse &&
            ast.payments &&
            ast.payments.length &&
            ast.payments.map((i, index) => {
              return (
                <Row key={index}>
                  <Col span={10}>{`${i.paymentTypeName}`}</Col>
                  <Col span={6}>
                    {`${i.amount}`}
                    {i.paymentName == "self_pbm_points_deduction"
                      ? "积分"
                      : "元"}
                    {ast.orderStatus != 0 && !ast.isUse && isover
                      ? `(扣${i.deductAmount}${
                          i.paymentName == "self_pbm_points_deduction"
                            ? "分"
                            : "元"
                        })`
                      : ""}
                  </Col>
                </Row>
              );
            })
          : null}
        {ast && ast.payStatus ? (
          ast.orderStatus != 0 && ast.isUse ? (
            <Checkbox
              style={{ display: "flex", alignItems: "center", marginTop: 15 }}
              onChange={(e) => this.onCheckChange(e)}
            >
              会员出现重大疾病症状，申请全额退款
            </Checkbox>
          ) : null
        ) : null}
        {ast && ast.payStatus ? (
          ast.orderStatus != 0 && !ast.isUse && isover ? (
            <Checkbox
              style={{ display: "flex", alignItems: "center", marginTop: 15 }}
              onChange={(e) => this.onCheckChange(e)}
            >
              会员出现重大疾病症状，申请全额退款
            </Checkbox>
          ) : null
        ) : null}
      </Modal>
    );
  }

  // 撤单
  revocationOrder(data) {
    this.props.getInsuranceRevokeOrderList(data.orderId);
    this.setState({
      canshow: true,
      selectOrder: data,
    });
  }

  // 点击列表激活
  async activate(data) {
    // 获取订单是否需要问询
    const inquiryData = await api.getInsuranceInquiries(
      data.insurancePackageId
    );
    if (inquiryData && inquiryData.needInquiry) {
      // inquiryData.inquiryType === 1 ? 第三方问询 : 本地问询
      if (inquiryData.inquiryType) {
        // 第三方问询避免数据同步失败, 激活前先同步数据, 如果返回true,代表已激活成功,如果返回false,则需要跳转重新激活
        const result = await api.insureInsureOrderNo(data.teamOrderNo, []);
        if (result) {
          message.success("激活成功");
          setTimeout(() => {
            this.table.reload();
          }, 100);
        } else {
          // 获取订单详情
          const insuranceOrderInfo = await api.getOriginInsuranceOrderInfo(
            data.orderId
          );
          // 保险公司编码
          let productGradeCode = "";
          let { orderProduct = [] } = insuranceOrderInfo;
          if (orderProduct) {
            for (let i = 0; i < orderProduct.length; i++) {
              if (orderProduct[i].productType === 1) {
                productGradeCode = orderProduct[i].productGradeCode;
                break;
              }
            }
          }
          let href =
            location.origin +
            "/patientInsurance" +
            `?orderId=${data.orderNo}&teamOrderNo=${data.teamOrderNo}&a=1`;

          href = encodeURIComponent(href);

          console.log("/patientInsurance href:", href);

          const url = `${inquiryData.inquiryUrl}?name=${data.insuredName}&cardNo=${data.insuredIdCard}&productGradeCode=${productGradeCode}&orderId=${data.teamOrderNo}&returnUrl=${href}`;
          // const url = `https://uat-channelh5.pubmi.cn/normalProduct/housepopup?name=雷海彦&cardNo=11010119661109673X&orderId=vpo2020110900000883&returnUrl=${encodeURIComponent(href)}`
          window.location.href = url;
        }
      } else {
        let inquiryId = +inquiryData.inquiryId;
        if (inquiryId === 1 || inquiryId === 4) {
          // 需求2017，众惠问询进行升级
          inquiryId = 6;
        } else if (inquiryId === 2) {
          inquiryId = 4;
        } else if (inquiryId === 3) {
          inquiryId = 5;
        }

        // 获取保险部问询列表
        let enquiryList = await api.getEnquiryList(inquiryId);
        this.setState({
          activateModalShow: true,
          orderInfo: data,
          enquiryList: enquiryList || [],
        });
      }
    } else {
      console.log("无需问询");
    }
  }

  // 问询弹窗关闭
  activateCancel = () => {
    this.setState({
      activateModalShow: false,
      orderInfo: null,
      enquiryList: [],
    });
    setTimeout(() => {
      this.table.reload();
    }, 300);
  };

  submit() {
    this.props.subRevokeOrderRes({
      orderId: this.state.selectOrder.orderId,
      ischeck: this.state.ischeck,
    });
    this.setState({
      canshow: false,
      ischeck: false,
    });
    setTimeout(() => {
      this.table.reload();
    }, 300);
  }

  checkOrder(item) {
    history.push(
      `/patientRevokeOrderDetail/${item.orderId}?r=${encodeURIComponent(
        this.props.router.fullPath
      )}`
    );
    this.setState({
      canshow: false,
    });
  }

  hideModal() {
    this.setState({
      canshow: false,
      ischeck: false,
    });
  }

  checkPayOrder(data) {
    Modal.confirm({
      title: `请确认该订单已有线下现金支付完成，现金支付金额：${data.amount}元？`,
      okText: "确定",
      cancelText: "取消",
      onOk: () => {
        this.props.cancelGroupInsurance(data.insurId);
      },
      onCancel() {},
    });
  }
  //搜索时
  handleBtnSearch = (value) => {
    //深拷贝一组数据
    let list = cloneDeep(this.state.insurancePackage2);
    let filterArr = [];
    //判断时数组还是字符
    if (value.substring(0, 2) === "IP") {
      filterArr = list.filter((item) => item.packageCode === value);
    } else {
      filterArr = list.filter(
        (item) => item.insurancePackageName.indexOf(value) >= 0
      );
    }
    // if(isNaN(Number(value))){
    //     //非数字匹配名字
    //     filterArr=list.filter(item=>(item.insurancePackageName).indexOf(value)>=0)
    // }else{
    //     //数字精确匹配
    //     filterArr=list.filter(item=>item.packageCode.toString()===value)
    // }
    this.setState({
      insurancePackage: filterArr,
    });
    if (!value) {
      console.log("woshi ", this.state.insurancePackage);
      this.setState({
        insurancePackage: this.state.insurancePackage2,
      });
    }
  };
  //改变时
  handleBtnChange = (value) => {
    console.log(value);
    // const name=this.state.insurancePackage2.filter(item=>item.packageId===value)
    // this.setState({
    //     packageId:name.insurancePackageName
    // })
    // const { setFieldsValue } = this.props.form
    // setFieldsValue({'packageId':value})
  };
  // 显示会员卡片
  showCustomerCard = (id) => {
    // console.log('showCustomerCard id:', id);
    this.setState({
      customerCardVisible: true,
      currentCustomerId: id,
    });
  };
  hideCustomerCard = () => {
    this.setState({
      customerCardVisible: false,
    });
  };
  render() {
    const {
      visible,
      confirmDateExplain,
      confirmDate,
      packageId,
      insurancePackage,
    } = this.state;
    const options =
      insurancePackage &&
      insurancePackage.map((item, index) => {
        return (
          <Option key={item.packageId}>
            {item.insurancePackageName}({item.packageCode})
          </Option>
        );
      });
    return (
      <div className="task_insurance_orderList">
        <CustomerCart
          id={this.state.currentCustomerId}
          visible={this.state.customerCardVisible}
          hideCustomerCard={this.hideCustomerCard}
        ></CustomerCart>
        <TablePage
          def={tableDef}
          data={this.props.insurancesOrderList}
          autoLoad={false}
          onLoadData={this.loadData}
          onExportData={this.exportData}
          onResetData={this.resetData}
          tableRef={(table) => (this.table = table)}
          rowKey="insurId"
          renderFormFields={(values, loadData, setValues, exportData) => {
            let searchProps;
            switch (values.type) {
              case "1":
                searchProps = { placeholder: "请输入服务对象" };
                break;
              case "3":
                searchProps = { placeholder: "请输入会员服务单" };
                break;
              case "2":
                searchProps = { placeholder: "请输入对象身份证号" };
                break;
              case "4":
                searchProps = { placeholder: "请输入销售渠道码" };
                break;
              case "5":
                searchProps = { placeholder: "请输入购买人" };
                break;
              default:
                searchProps = { disabled: true };
                break;
            }
            return (
              <Row gutter={8} className="block filter-box">
                <Col span={3} key="1">
                  <Form.Item field="type" height="auto">
                    <Select>{QueryKeyChoices.map(mapChoiceToOption)}</Select>
                  </Form.Item>
                </Col>
                <Col span={3} key="2">
                  <Form.Item field="search" height="auto">
                    <Input {...searchProps} onPressEnter={loadData} />
                  </Form.Item>
                </Col>
                <Col span={3}>
                  <Form.Item field="packageId" height="auto">
                    <Select
                      showSearch
                      placeholder="请输入服务包名称"
                      defaultActiveFirstOption={false}
                      showArrow={false}
                      filterOption={false}
                      onSearch={debounce(this.handleBtnSearch, 500)}
                      onChange={this.handleBtnChange}
                      notFoundContent={null}
                      allowClear
                    >
                      {options}
                    </Select>
                  </Form.Item>
                </Col>
                <Col span={3}>
                  <Form.Item field="status" height="auto">
                    <Select placeholder="请选择订单状态" allowClear>
                      {orderTypes.map(mapChoiceToOption)}
                    </Select>
                  </Form.Item>
                </Col>
                <Col span={3}>
                  <Form.Item field="payStatus" height="auto">
                    <Select placeholder="请选择支付状态" allowClear>
                      {isPayStatusChoices.map(mapChoiceToOption)}
                    </Select>
                  </Form.Item>
                </Col>
                <Col span={3}>
                  <Form.Item field="startTime" height="auto">
                    <DateRangePicker
                      size="default"
                      placeholder="请选择登记时间"
                    />
                  </Form.Item>
                </Col>
                <Col span={2}>
                  <Button
                    onClick={loadData}
                    style={{ width: "100%", minWidth: 0 }}
                    type="primary"
                  >
                    查询
                  </Button>
                </Col>
                <Col span={2}>
                  <HasPermission match="insurance.edit">
                    <Button
                      onClick={this.openNewOrderInsuranceModal}
                      style={{ width: "100%", minWidth: 0 }}
                      type="primary"
                    >
                      新建
                    </Button>
                  </HasPermission>
                </Col>
                <Col span={2}>
                  <HasPermission match="insurance.order.export">
                    <Button
                      onClick={exportData}
                      style={{ width: "100%", minWidth: 0 }}
                      type="primary"
                    >
                      导出
                    </Button>
                  </HasPermission>
                </Col>
              </Row>
            );
          }}
          // renderFooter={(values) => {
          //   return this.props.insurancesOrderList &&
          //     this.props.insurancesOrderList.list &&
          //     this.props.insurancesOrderList.list.length ? (
          //       <div
          //         style={{
          //           display: 'flex',
          //           flexDirection: 'row',
          //           alignItems: 'center',
          //         }}
          //       >
          //         <div
          //           style={{
          //             display: 'flex',
          //             alignItems: 'center',
          //             marginRight: 10,
          //           }}
          //         >
          //           <img src={reeor} style={{ width: 28 }} />
          //           <span className='clickable' style={{ color: '#C8161D' }}>
          //             实际年龄超出方案年龄
          //         </span>
          //         </div>
          //         <div style={{ display: 'flex', alignItems: 'center' }}>
          //           <img src={warning} style={{ width: 28 }} />
          //           <span className='clickable' style={{ color: '#F8BB34' }}>
          //             实际年龄将在一周内超出方案年龄
          //         </span>
          //         </div>
          //       </div>
          //     ) : null;
          // }}
        >
          <TableColumn
            title="会员服务单号"
            className="singleline max-w-200"
            dataIndex="orderNo"
            key="orderNo"
            onCellClick={this.showDetail}
            render={(text, insurance) => (
              <span className="clickable">{text}</span>
            )}
          />
          {/* <TableColumn
            title="服务对象"
            className="singleline"
            dataIndex="insuredName"
            key="insuredName"
            render={(text, insurance) => (
              <span
                style={{ textDecoration: "underline", cursor: "pointer" }}
                onClick={() => {
                  this.showCustomerCard(insurance.insuredId);
                }}
              >
                {text}
              </span>
            )}
          />
          <TableColumn
            title="对象身份证号"
            dataIndex="insuredIdCard"
            key="insuredIdCard"
          />
          <TableColumn
            title="手机号"
            className="singleline"
            dataIndex="insuredPhone"
            key="insuredPhone"
          /> */}
          <TableColumn
            title="会员服务包"
            className="singleline"
            dataIndex="insurancePackageName"
            key="insurancePackageName"
          />
          <TableColumn
            title="服务包编码"
            className="singleline"
            dataIndex="insurancePackageCode"
          />
          <TableColumn
            title="服务档次"
            className="singleline"
            dataIndex="insurancePackageGradeName"
            key="insurancePackageGradeName"
          />
          <TableColumn
            title="订单状态"
            className="singleline"
            dataIndex="status"
            key="status"
            render={(status, insurance) => {
              if (status === null || status === undefined) return "";
              const found = orderTypes.find((t) => t.value == `${status}`);
              if (found) {
                return <span>{found.label}</span>;
              }
              return <span>未知状态</span>;
            }}
          />
          <TableColumn
            title="缴费方式"
            className="singleline"
            dataIndex="payWay"
            key="payWay"
            render={(status, insurance) => {
              if (status === null || status === undefined) return "";
              const found = payType.find((t) => t.value == `${status}`);
              if (found) {
                return <span>{found.label}</span>;
              }
              return <span>未知方式</span>;
            }}
          />
          <TableColumn
            title="支付状态"
            className="singleline"
            dataIndex="payStatus"
            key="payStatus"
            render={(payStatus, insurance) => {
              if (payStatus === null || payStatus === undefined) return "";
              const found = isPayStatusChoices.find(
                (t) => t.value == `${payStatus}`
              );
              if (found) {
                return (
                  <span>
                    {found.label}
                    {insurance.payWay == 2 ? insurance.period : ""}
                  </span>
                );
              }
              return <span>未知状态</span>;
            }}
          />
          <TableColumn
            title="购买人"
            className="singleline"
            dataIndex="insurerName"
          />
          <TableColumn
            title="销售渠道"
            className="singleline"
            dataIndex="channelCode"
          />
          <TableColumn
            title="登记时间"
            className="singleline"
            dataIndex="orderDate"
            key="orderDate"
          />
          {/*
          <TableColumn
            title="操作"
            className="singleline"
            dataIndex="status"
            key="op"
            renderTip={() => null}
            render={(status, pool) => {
              let toggleBtn;
              if (status == 1 || status == 2 || status == 0 || status == 3) {
                toggleBtn = (
                  <span>
                    {testPermission("insurance.revoke") ? (
                      <span
                        className="clickable"
                        onClick={() => this.revocationOrder(pool)}
                      >
                        撤单
                      </span>
                    ) : null}
                    {testPermission("insurance.edit") && status === 2 ? (
                      <span
                        className="clickable"
                        onClick={() => this.activate(pool)}
                      >
                        激活
                      </span>
                    ) : null}
                  </span>
                );
              } else if (status == 6) {
                toggleBtn = (
                  <span>
                    <span
                      className="clickable"
                      onClick={() => this.checkOrder(pool)}
                    >
                      查看退款单
                    </span>
                  </span>
                );
              }
              return toggleBtn;
            }}
          />
          */}
        </TablePage>

        {this.renderModal()}

        {/* 问询弹窗 */}
        {/* {this.state.orderInfo ? (
          <ActivateModal
            show={this.state.activateModalShow}
            orderInfo={this.state.orderInfo}
            enquiryList={this.state.enquiryList}
            onCancel={this.activateCancel}
          />
        ) : null} */}
      </div>
    );
  }
}

export default connectRouter(connectState(InsuranceOrder));
